<template>
    <div>

        <ul class="mui-table-view">

            <li class="mui-table-view-cell mui-media" v-for="v in newsList" :key="v.id">
                <router-link :to="'/home/newslist/news/' + v.id">
                    <img class="mui-media-object mui-pull-left" :src="v.img_url">
                    <div class="mui-media-body">
                        <strong>{{ v.title }}</strong>
                        <p class='mui-ellipsis'>
                            <span>发布时间:{{ v.add_time | dateFormat }}</span>
                            <span>点击:{{ v.click }}次</span>
                        </p>
                    </div>
                </router-link>
            </li>

        </ul>

    </div>
</template>

<script>
    export default {
        data () {
            return {
                newsList:[],
            }
        },
        created () {
            this.getNewsList();
        },
        methods: {
            getNewsList () {
                this.$http.get('api/getnewslist').then( res => {
                    if ( res.body.status === 0 ) {
                        this.newsList = res.body.message;
                    } else {
                        this.$toast('获取新闻列表失败')
                    }
                })
            },
        },
    }
</script>

<style lang="scss" scoped>
    .mui-media-body {
        strong {
            font-size: 14px;
            color: #26a2ff;
        }
        .mui-ellipsis {
            display: flex;
            justify-content: space-between;
            font-size: 12px;
        }
    }
</style>

